package com.zpxt.zpxt.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.zpxt.zpxt.entity.Company;
import com.zpxt.zpxt.entity.Talent;
import com.zpxt.zpxt.serve.LoginServe;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author:hjx
 * @Description:登陆
 * @Date: Created in 15:18 2018/4/11
 * @Modified By:
 */
@CrossOrigin
@RestController
@RequestMapping("/login")
public class LoginController {
    @Resource(name="loginServe")
    LoginServe loginServe;

    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();

    @RequestMapping("/company")
    @ResponseBody
    public Company computerLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {

        String code = request.getParameter("code");
        String password = request.getParameter("password");

        Company company = loginServe.companyLogin(code,password);

        return company;
    }

    @RequestMapping("/talent")
    @ResponseBody
    public Talent talentLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {

        String code = request.getParameter("code");
        String password = request.getParameter("password");

        Talent talent = loginServe.talentLogin(code,password);

        return talent;
    }

}
